<?php

namespace App\Models;


use Dcat\Admin\Models\Administrator;
use Illuminate\Database\Eloquent\Model;

class UserProcess extends Model
{
	
    protected $table = 'user_processes';


    protected $fillable = [
        'user_id',
        'workshop_id',
        'processes_archives_ids'
    ];

    public function getProcessesArchivesIdsAttribute($processes_archives_ids)
    {
        return json_decode($processes_archives_ids, true);
    }

    public function setProcessesArchivesIdsAttribute($processes_archives_ids)
    {
        $this->attributes['processes_archives_ids'] = json_encode($processes_archives_ids);
    }

    public function user()
    {
        return $this->belongsTo(Administrator::class);
    }

    public function workshop()
    {
        return $this->belongsTo(Workshop::class);
    }
}
